package com.financial.business.integral.service.impl;

import com.financial.business.integral.constants.FinancialPayIntegralEnumConstants;
import com.financial.business.integral.service.FinancialIntegralPayService;
import com.financial.business.integral.service.yd.FinancialYDIntegralPayService;
import com.financial.business.integral.utils.JsonUtils;
import com.financial.business.integral.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class FinancialIntegralPayServiceImpl implements FinancialIntegralPayService {
	public static final Logger logger = LoggerFactory.getLogger(FinancialIntegralPayServiceImpl.class);

	@Autowired
	private FinancialYDIntegralPayService financialYDIntegralPayService;

	@Override
	public ApiResult pay(String requestParam) {
		logger.info("FinancialPayIntegralServiceImpl.pay()-----积分支付获取到的json信息为："+requestParam);
		/*解析参数信息判断支付渠道*/
		Map<String,Object> map = JsonUtils.jsonToMap(requestParam);
		String payChannelNo=(String)map.get("pay_channel_no");
		logger.info("FinancialPayIntegralServiceImpl.pay()-----积分支付支付渠道为："+payChannelNo);
		ApiResult apiResult=ApiResult.failure(FinancialPayIntegralEnumConstants.ENUM_RETURNMESSAGE_FAIL);
		/*判断支付渠道*/
		if(payChannelNo.equalsIgnoreCase(FinancialPayIntegralEnumConstants.ENUM_PAYCHANNEL_YDINTEGRAL)){
			/*优店平台积分支付*/
			apiResult=financialYDIntegralPayService.pay(requestParam);
		}
		return apiResult;
	}
}
